<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ page isELIgnored="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
  <head>
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.custom.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script>    
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
  </head>
  <style type="text/css">
    .ui-jqgrid tr.jqgrow td 
	{
		/* jqGrid cell content wrap  */
		white-space: normal !important;
	        height :auto;
	}
	
	th.ui-th-column div
	{
		/* jqGrid columns name wrap  */
		white-space:normal !important;
		height:auto !important;
		padding:0px;
	}
 </style>
  <script type="text/javascript">  
   $(function(){ 
	    $("#chax").button();
	    loadTab();    
  });
  
  //加载表
  function loadTab(){ 
      $("#myTab").jqGrid({      
		    url:'<s:url value="/hwjs"/>/findHtGrid',   
		    datatype: 'json',
		    mtype: 'post',         
		   	colNames:['选择','合同编号', '出卖人','买受人','发货单位','收货单位','发站','到站','maisdwjsrmc','chumdwjsrmc','hetid','fazbm','daozbm'],
		   	colModel:[
		      	{name:'caoz',index:'sysid',width:60,align:"center"}, 
		   		{name:'hetbh',index:'hetbh', width:250},
		   		{name:'chumdwmc',index:'chumdwmc', width:200 , sortable:false},
		   		{name:'maisdwmc',index:'maisdwmc', width:200, sortable:false },		
		   		{name:'fahdwmc',index:'fahdwmc', width:200, sortable:false},		
		   		{name:'shouhdwmc',index:'shouhdwmc', width:200, sortable:false},
		   		{name:'fazmch',index:'fazmch', width:150, sortable:false},		
		   		{name:'daozmch',index:'daozmch', width:150, sortable:false},
		   		{name:'maisdwjsrmc',index:'maisdwjsrmc', hidden:true },
		   		{name:'chumdwjsrmc',index:'chumdwjsrmc', hidden:true},	
		   		{name:'hetid',index:'hetid', hidden:true},
		   		{name:'fazbm',index:'fazbm', hidden:true },
		   		{name:'daozbm',index:'daozbm', hidden:true}	
		   	],
		    jsonReader: {
		           repeatitems : false, 
		           id: 'sysid'
		         },   
		    height:300, 
		    width:750,	
		   	rowNum:10,
		   	rowList:[10,30,50],     	
		   	pager: '#pager13',
		   	rownumbers: true,   	 
		    viewrecords: true,
		    sortorder: 'desc', 
		    caption: "合同列表",
			gridComplete:function()
				{ //在此事件中循环为每一行添加修改和删除链接 	
					var ids=$("#myTab").jqGrid('getDataIDs'); 
					//alert(ids);
					for(var j=0; j<ids.length; j++)
					{		
					     id=ids[j];		    
						 caoz="<a href='#' style='color:#f60' onclick='choose("+ id +")'>选择</a>";
						 $("#myTab").jqGrid('setRowData',id, { caoz: caoz }); 
						
					}
				}		
	       });
	  }
  
	// 查询
	function search(){ 
	  var formdata = $("#form1").serialize(); 
	  $("#myTab").jqGrid('setGridParam',{   
	                          url:'<s:url value="/hwjs"/>/findHtGrid?'+formdata,
							  mtype:'post',
							  page:1}).trigger("reloadGrid");  
	}
	
	//选择
	function choose(id) { //选择对应合同
	    var rowData = $("#myTab").jqGrid("getRowData", id);  
	    var parent=window.dialogArguments; 
	    parent.document.getElementById("hetbh").value=rowData.hetbh;
	    parent.document.getElementById("chumdwmc").value=rowData.chumdwmc;
	    parent.document.getElementById("maisdwmc").value=rowData.maisdwmc;
	    parent.document.getElementById("fahdwmc").value=rowData.fahdwmc;
	    parent.document.getElementById("shouhdwmc").value=rowData.shouhdwmc;
	    parent.document.getElementById("fazmch").value=rowData.fazmch;
	    parent.document.getElementById("daozmch").value=rowData.daozmch;
	    parent.document.getElementById("maisdwjsrmc").value=rowData.maisdwjsrmc;
	    parent.document.getElementById("chumdwjsrmc").value=rowData.chumdwjsrmc;
	    parent.document.getElementById("hetid").value=rowData.hetid;
	    parent.document.getElementById("fazbm").value=rowData.fazbm;
	    parent.document.getElementById("daozbm").value=rowData.daozbm;
	    parent.document.getElementById("fazbm").value=rowData.fazbm;
	    parent.document.getElementById("daozbm").value=rowData.daozbm;
	    window.close(); 
	}

</script>  
<body>  
<div id="best1">
<form id="form1" method="post">
<table id="list_search"  style="width:80%"  cellpadding="0" cellspacing="0" border="0"> 
        <tr>
            <td>
            	合同编号:
            </td>
            <td>
            	<input type="text" class="longtextbox" name="aa" /> 
            </td>
            <td style="text-align:left">
                <input id="chax" type="button" value="查询" onclick="search();"/>
            </td>
        </tr>
  </table>
  </form>
    <table id="list_search" cellpadding="0" cellspacing="0" border="0">
    </table>
    <table id="myTab" class="scroll" cellpadding="0" cellspacing="0" style="width:50%" ></table>  
   	<div id="pager13" class="scroll"></div>  
   	<div id="message" class="scroll"></div> 
</div> 
</body>
</html>
